<template>
  <div class="app-container">
    <!--工具栏-->
    <div class="head-container">
      <!--如果想在工具栏加入更多按钮，可以使用插槽方式， slot = 'left' or 'right'-->
      <crudOperation :permission="permission" />
      <!--表单组件-->
      <el-dialog :close-on-click-modal="false" :before-close="crud.cancelCU" :visible.sync="crud.status.cu > 0" :title="crud.status.title" width="500px">
        <el-form ref="form" :model="form" :rules="rules" size="small" label-width="80px">
          <el-form-item label="组织名称" prop="name">
            <el-input v-model="form.name" style="width: 370px;" />
          </el-form-item>
          <el-form-item label="营业执照">
            <el-input v-model="form.businessLicense" style="width: 370px;" />
          </el-form-item>
          <el-form-item label="行业">
            <el-input v-model="form.industry" style="width: 370px;" />
          </el-form-item>
          <el-form-item label="法人代表">
            <el-input v-model="form.legal" style="width: 370px;" />
          </el-form-item>
          <el-form-item label="所属区域">
            <el-input v-model="form.area" style="width: 370px;" />
          </el-form-item>
          <el-form-item label="性质">
            <el-input v-model="form.nature" style="width: 370px;" />
          </el-form-item>
          <el-form-item label="规模">
            <el-input v-model="form.scale" style="width: 370px;" />
          </el-form-item>
          <el-form-item label="联系人">
            <el-input v-model="form.contactPerson" style="width: 370px;" />
          </el-form-item>
          <el-form-item label="联系手机">
            <el-input v-model="form.contactPhone" style="width: 370px;" />
          </el-form-item>
          <el-form-item label="联系职务">
            <el-input v-model="form.contactJob" style="width: 370px;" />
          </el-form-item>
          <el-form-item label="联系电邮">
            <el-input v-model="form.contactEmail" style="width: 370px;" />
          </el-form-item>
          <el-form-item label="联系传真">
            <el-input v-model="form.contactFax" style="width: 370px;" />
          </el-form-item>
          <el-form-item label="联系固话">
            <el-input v-model="form.contactTel" style="width: 370px;" />
          </el-form-item>
          <el-form-item label="登记时间">

            <el-date-picker v-model="form.regDate" type="date" value-format="yyyy-MM-dd" style="width: 370px;" />

          </el-form-item>
        </el-form>
        <div slot="footer" class="dialog-footer">
          <el-button type="text" @click="crud.cancelCU">取消</el-button>
          <el-button :loading="crud.cu === 2" type="primary" @click="crud.submitCU">确认</el-button>
        </div>
      </el-dialog>
      <!--表格渲染-->
      <el-table ref="table" v-loading="crud.loading" :data="crud.data" size="small" style="width: 100%;" @selection-change="crud.selectionChangeHandler">
        <el-table-column type="selection" width="55" />
        <el-table-column prop="name" label="组织名称" />
        <el-table-column prop="businessLicense" label="营业执照" />
        <el-table-column prop="industry" label="行业" />
        <el-table-column prop="legal" label="法人代表" />
        <el-table-column prop="area" label="所属区域" />
        <el-table-column prop="nature" label="性质" />
        <el-table-column prop="scale" label="规模" />
        <el-table-column prop="contactPerson" label="联系人" />
        <el-table-column prop="contactPhone" label="联系手机" />
        <el-table-column prop="contactJob" label="联系职务" />
        <el-table-column prop="contactEmail" label="联系电邮" />
        <el-table-column prop="contactFax" label="联系传真" />
        <el-table-column prop="contactTel" label="联系固话" />
        <el-table-column prop="regDate" label="登记时间" />
        <el-table-column v-permission="['admin','omBaseInfo:edit','omBaseInfo:del']" label="操作" width="150px" align="center">
          <template slot-scope="scope">
            <udOperation
              :data="scope.row"
              :permission="permission"
            />
          </template>
        </el-table-column>
      </el-table>
      <!--分页组件-->
      <pagination />
    </div>
  </div>
</template>

<script>
import crudOmBaseInfo from '@/api/psp/om/omBaseInfo'
import CRUD, { presenter, header, form, crud } from '@crud/crud'
// import rrOperation from '@crud/RR.operation'
import crudOperation from '@crud/CRUD.operation'
import udOperation from '@crud/UD.operation'
import pagination from '@crud/Pagination'

const defaultForm = { id: null, createBy: null, updateBy: null, createTime: null, updateTime: null, name: null, businessLicense: null, industry: null, legal: null, area: null, nature: null, scale: null, contactPerson: null, contactPhone: null, contactJob: null, contactEmail: null, contactFax: null, contactTel: null, regDate: null }
export default {
  name: 'OmBaseInfo',
  components: { pagination, crudOperation, udOperation },
  mixins: [presenter(), header(), form(defaultForm), crud()],
  cruds() {
    return CRUD({ title: '基础信息', url: 'api/omBaseInfo', sort: 'id,desc', crudMethod: { ...crudOmBaseInfo }})
  },
  data() {
    return {
      permission: {
        add: ['admin', 'omBaseInfo:add'],
        edit: ['admin', 'omBaseInfo:edit'],
        del: ['admin', 'omBaseInfo:del']
      },
      rules: {
        name: [
          { required: true, message: '组织名称不能为空', trigger: 'blur' }
        ]
      }
    }
  },
  methods: {
    // 获取数据前设置好接口地址
    [CRUD.HOOK.beforeRefresh]() {
      return true
    }
  }
}
</script>

<style scoped>

</style>
